package com.zhangbo.study.designpatternlearning.combination;

import java.sql.Array;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Menu extends MenuComponent {

    private List<MenuComponent> menuComponents = new ArrayList<>();

    private String name;

    private String descripton;

    public Menu(String name, String descripton) {
        this.name = name;
        this.descripton = descripton;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public String getDescription() {
        return descripton;
    }

    @Override
    public void add(MenuComponent menuComponent) {
        menuComponents.add(menuComponent);
    }

    @Override
    public void print() {
        System.out.print("\n " + getName());
        System.out.println("\n " + getDescription());
        System.out.println("-----------------------------");
        Iterator<MenuComponent> iterator = menuComponents.iterator();
        while (iterator.hasNext()) {
            MenuComponent next = iterator.next();
            next.print();
        }
    }

}
